package cn.tedu.boyou.search.template;

import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

@Document(indexName = "boyou_sale",type = "sale")
@Setter@Getter
public class SaleTemplate implements Serializable{

    public static final String INDEX_NAME = "boyou_sale";
    public static final String TYPE_NAME = "sale";

    @Id
    @Field(store = true,index = false, type = FieldType.Long)
    private Long id; //旅游行程id

    @Field(store = true, index = true, type = FieldType.Long)
    private Long originId;
    @Field(store = true, index = true, type = FieldType.Keyword)
    private String originName;

    @Field(store = true, index = true, type = FieldType.Long)
    private Long destId;
    @Field(store = true, index = true, type = FieldType.Keyword)
    private String destName;

    @Field(index = true, store = true, type = FieldType.Keyword)
    private String headImgUrl;

    @Field(index = true, store = true, type = FieldType.Integer)
    private int soldAmount;
    @Field(index = true, store = true, type = FieldType.Integer)
    private int totalAmount;

    @Field(index = true, store = true, type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_max_word")
    private String title;

    @Field(pattern = "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis",type = FieldType.Date, format = DateFormat.custom)
    private Date state_schedule;
    @Field(pattern = "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis",type = FieldType.Date, format = DateFormat.custom)
    private Date end_schedule;

    @Field(index = true, store = true, type = FieldType.Long)
    private Long shopId;
    @Field(index = true, store = true, type = FieldType.Keyword)
    private String shopName;

    @Field(index = true, store = true, type = FieldType.Long)
    private Long minPrice;
    @Field(index = true, store = true, type = FieldType.Long)
    private Long maxPrice;
    @Field(index = true, store = true, type = FieldType.Object)
    private TrafficTemplate traffic;

    @Field(index = true, store = true, type = FieldType.Object)
    private List<SaleTagTemplate> saleTags;

    @Field(index = true, store = true, type = FieldType.Object)
    private RouteTemplate hotRoute;
    @Field(index = true, store = true, type = FieldType.Object)
    private RouteTemplate funRoute;

    @Field(index = true, store = true, type = FieldType.Object)
    private SaleTypeTemplate saleType;

    @Field(index = true, store = true, type = FieldType.Boolean)
    private boolean promotion;
}
